<%@ taglib uri="http://java.sun.com/jsp/jstl/core" prefix="c" %>
<%@taglib uri="/WEB-INF/tld/struts-html.tld" prefix="html" %>
<%@taglib uri="/WEB-INF/tld/struts-bean.tld" prefix="bean" %>
<%@ taglib uri="/WEB-INF/tld/struts-logic.tld" prefix="logic"%>
<%@ taglib prefix="fn" uri="http://java.sun.com/jsp/jstl/functions" %>
<%
String monthLater = AMResourceManager.getMessage(AMResourceKeyConstants.MSG_MONTHLATER);
String inputTime = AMResourceManager.getMessage(AMResourceKeyConstants.FIELD_INPUTTIME);
String inputDate = AMResourceManager.getMessage(AMResourceKeyConstants.FIELD_INPUTDATE);
String project = AMResourceManager.getMessage(AMResourceKeyConstants.FIELD_PROJECT);
String confirmMessage = AMResourceManager.getMessage(AMResourceKeyConstants.MSG_CONFIRMMESSAGE);
String deleteMessage = AMResourceManager.getMessage(AMResourceKeyConstants.MSG_DELETEMESSAGE);
String saveSuccessMessage = AMResourceManager.getMessage(AMResourceKeyConstants.MSG_SAVESUCCESSMESSAGE);
String confirmSuccessMessage = AMResourceManager.getMessage(AMResourceKeyConstants.MSG_CONFIRMSUCCESSMESSAGE);
%>
<html>
<head>
<title><bean:message key="menu.item.inputWorkingTime"/></title>
<link rel="stylesheet" href="<c:url value="/css/inputdailyattendance/inputdailyattendance.css" />" type="text/css">
</head>
<script language="JavaScript">
	function fnConfirmClose()
	{
	 if(window.event.clientX < 0 || window.event.clientY < 0)
	    return "Do you want to close browser?";
	else
	    return;
	}
	window.onbeforeunload = fnConfirmClose;
	var projectChecked = false;
	var seriCheck = false;
    
    function getWorkingTimeInfo(workingTimeId) {
    	resetWorkingTime();
		$.getJSON("workingtimeinfo.do?id="+workingTimeId,
			function(data){
				$('label[id="plannedWorkingStartTime"]').text(data.startTime);
				$('label[id="plannedWorkingEndTime"]').text(data.endTime);
				$('label[id="plannedWorkingTime"]').text(data.fixedWorkingTime);
				$('label[id="autoOvertimeApplyTime"]').text(data.overtimeAutoApplyTime);
			});
	}
    $(document).ready(function(){
    	var couter = 0;
    	$("#formInputDailyAttendance").submit(function()
    	{
    		couter++;
    	if ( couter > 1 ) { return false; }
    	});
    	var totalOperationTime = setTotalTimeByColumn();
    	$('label[id="totalEffort"]').text(totalOperationTime);
    	$('#totalOperationTime').val(totalOperationTime);
    	
    	$('.workingTime').focusout(function () {
    		this.value = chkCode(this.value);
    		if(checkInputTime(this)){
    			var totalOperationTime = setTotalTimeByColumn();
    			$('label[id="totalEffort"]').text(totalOperationTime);
    			$('#totalOperationTime').val(totalOperationTime);
    		}
    	});
    	
    	$('#txtYear').datepick({
    		showOnFocus:false,
    		dateFormat: "yyyymmdd,DD",
    		onSelect: selectDateTime
    		});
    	$('#datepickButton').click(function() {
      		$('#txtYear').datepick('show');
		});
    	$('#startDatePicker').datepick({
    		showTrigger: '#startDateImg',
    		dateFormat: "mm/dd",
    		onSelect: resetWorkingTime
    	});
    	$('#endDatePicker').datepick({
    		showTrigger: '#endDateImg',
    		dateFormat: "mm/dd",
    		onSelect: resetWorkingTime
    	});
    	$('#dateInline').datepick({
    		dateFormat: "yyyymmdd,DD",
    		altField:'#txtYear',
    		onSelect: selectDateTime
    		});
    	
    	var jobSelected = $("select[name*='jobDivision']").selectedValues();
		checkJobDivision(jobSelected[0]);
		
		$('.inputTime').focusout(function () {
			this.value = chkCode(this.value);
    		checkInputTime(this);
    	});
		
		$('.projectCodeCheck').focusout(function () {
    		checkProjectCodeAndSeri(this);
    	});
    	
		$('.projectSeriCheck').focusout(function () {
			checkProjectCodeAndSeri(this);
    	});
		
		$('.kokiGroup').click(function () {
			var checkboxName = $(this).attr("name");
			
			if (checkboxName.indexOf("chokkoFlag") > -1) {
				$("input:checkbox[name*='chokkiFlag']").removeAttr("checked");
				$("input:hidden[name*='chokkiFlag']").val("false");
				$("input:hidden[name*='chokkoFlag']").val($(this).is(':checked') ? "true" : "false");
			}
			else if (checkboxName.indexOf("chokkiFlag") > -1) {
				$("input:checkbox[name*='chokkoFlag']").removeAttr("checked");
				$("input:hidden[name*='chokkoFlag']").val("false");
				$("input:hidden[name*='chokkiFlag']").val($(this).is(':checked') ? "true" : "false");
			}
    	});
		
		$('.timeFlag').click(function () {
			var checkboxName = $(this).attr("name");
			$("input:hidden[name='" + checkboxName + "']").val($(this).is(':checked') ? "true" : "false");
    	});
		
		$('.checkDateField').focusout(function () {
			this.value = chkCode(this.value);
    		checkInputDate(this);
    	});
		
		$('#currYear').val($('#txtYear').val());
		$('#currMonth').val($('#txtMonth').val());
		$('#currDay').val($('#txtDay').val());
		
		$('.resetWorkingTime').change(function () {
			resetWorkingTime();
    	});
    });
    
    function selectDateTime(){
    	
    	var currentYear = parseInt((new Date).getFullYear());
    	var currentMonth = parseInt((new Date).getMonth()+1);
    	var currentDay = parseInt((new Date).getDay());
    	if($('#txtYear').val() != null && $('#txtYear').val().length != 0){
    		var year = $('#txtYear').val().substring(0,4);
    		var month = $('#txtYear').val().substring(4,6);
    		var day =  $('#txtYear').val().substring(6,8);
    		var dayName =  $('#txtYear').val().substring(9,($('#txtYear').val().length)-2);
    		if(currentYear < year || ((currentMonth < month) && (currentYear == year))){
    			$('#txtYear').val(currentYear);
    			alert("<bean:message key='Alarm.W1055.error' arg0='<%=monthLater%>' />");
    			return;
    		}
    		if(isDateChanged(year, month, day)){
    			$('#dateChanged').val("true");
    			initDataShow();
    		} else {
    			$('#dateChanged').val("false");
    		}
    		$('#txtYear').val(year);
    		$('#txtMonth').val(month);
    		$('#txtDay').val(day);
    		$('#txtDayName').val(dayName);
    		$('#currYear').val(year);
    		$('#currMonth').val(month);
    		$('#currDay').val(day);
    	}
    }
    
    function isDateChanged(year, month, day) {
    	return $('#currYear').val() != year || $('#currMonth').val() != month || $('#currDay').val() != day;
    }
    
    function initDataShow(){
    	$('#dailyWorkingApprovalStatus').text("");
    	$('#plannedWorkingStartTime').text("");
    	$('#plannedWorkingEndTime').text("");
    	eraseDataForCheckbox("kokiGroup");
    	$('#substituteHoliday').val("");
    	$('#comingWorkDay').text("");
    	$('#comingWorkTime').text("");
    	$('#leavingWorkDay').text("");
    	$('#leavingWorkTime').text("");
    	$('#startDatePicker').val("");
    	$('#workingStartTime').val("");
    	$('#endDatePicker').val("");
    	$('#workingEndTime').val("");
    	$('#workingTime').text("");
    	$('#plannedWorkingTime').text("");
    	$('#autoOvertimeApplyTime').text("");
    	eraseDataForCheckbox("timeFlag");
    	$('#screenRestTime').val("");
    	if($('#paidHoliday')){
    	   $('#paidHoliday').val("");
    	}
    	$('#comment').val("");
    	$('#fixedWorkingTime').text("");
    	$('#substituteHolidayTime').val("");
    	$('#insufficentTime').text("");
    	$('#overtime').val("");
    	$('#satWorkingTime').val("");
    	$('#holidayWorkTime').val("");
    	$('#nightWorkTime').val("");
    	$('#satNightWorkTime').val("");
    	$('#holidayNightWorkTime').val("");
    	$('#overTimeWorkingPerMonth').text("");
    	$('#nightShiftWork').val("");
    	$('#announcement').val("");
    	
    	//delete effort table data
    	var infoProjectTable = $("table[id='infoProjectTable']");
    	if (infoProjectTable){
	      $(infoProjectTable).find("tr").remove();
	      for(var i=0; i<4; i++){
	    	  $(infoProjectTable).append(
				    "<tr height='22px'>" +
			    	"<td width='30px'>&nbsp;&nbsp;</td>" +
			        "<td width='110px'>&nbsp;&nbsp;</td>" +
					"<td width='30px'>&nbsp;&nbsp;</td>" +
					"<td width='30px'>&nbsp;&nbsp;</td>" +
					"<td width='80px'>&nbsp;&nbsp;</td>" +
					"<td width='90px'>&nbsp;&nbsp;</td>" +
					"<td width='26px'>&nbsp;&nbsp;</td>" +
					"<td width='100px'>&nbsp;&nbsp;</td>" +
					"<td width='50px'>&nbsp;&nbsp;</td>" +
					"<td>&nbsp;&nbsp;</td>" +
	           		"</tr>"
   				  );
	      }
    	}
    	
    	$('#totalEffort').text("");
    	
    	//disable components
    	var myCompIds = ["btnDelete","btnSave","btnConfirm","btnReCalculate","timeDivision","jobDivision",
    	                 "substituteHoliday","startDatePicker","workingStartTime","endDatePicker","workingEndTime",
    	                 "comingLateFlag","leavingEarlyFlag","commutingDelayFlag","screenRestTime","btnRestTimeDetail","paidHoliday",
    	                 "comment","substituteHolidayTime","overtime","satWorkingTime","holidayWorkTime","nightWorkTime",
    	                 "satNightWorkTime","holidayNightWorkTime","nightShiftWork","btnAddEffort","btnDeleteEffort"];
    	
    	disableComponentById(myCompIds);
    }
    
    function eraseDataForCheckbox(className){
    	$('.'+className).each(function(){
    		$(this).removeAttr("checked");
    	});
    }
    
    function disableComponentById(compIds){
    	for (var i=0; i < compIds.length; i++){
    		var comp = $('#'+compIds[i]);
    		if (comp){
    		  $(comp).attr("disabled", "disabled");
    		}
    	}
    }
    
    function setTotalTimeByColumn(){
    	var sum = 0;
    	var cellValueTemp ="";
    	var cellHours = 0;
 	    var cellMinutes = 0;
 	    
		$('.workingTime').each(function(){
			cellValueTemp = $(this).val();
			if(!(cellValueTemp == "")){
	    		cellHours = cellHours + parseFloat(cellValueTemp.substring(0,2));
	    		cellMinutes = cellMinutes + parseFloat(cellValueTemp.substring(3,6));
	    	}
		});
		
		cellHours = cellHours + parseInt(cellMinutes/60);
	  	cellMinutes = cellMinutes % 60;
	   	cellHours = (cellHours < 10) ? ("0"+cellHours) : cellHours;
	   	cellMinutes = (cellMinutes < 10) ? ("0"+cellMinutes) : cellMinutes;
	   	sum = cellHours + ":" + cellMinutes;
		return sum;
    }
    
    function checkInputTime(field){
    	var x = field.value;
    	var isValid = true;
    	if(x.length == 0){
    		return isValid;
    	}
    	
    	if(x.length < 5 || !isNumeric(x.substring(0,2)) || x.substring(0,2) < 0 || x.substring(0,2) > 23
    			|| x.substring(2,3) != ":" || !isNumeric(x.substring(3,6)) || x.substring(3,6) < 0 || x.substring(3,6) > 59){
    		isValid = false;
    	}
    	
    	if(!isValid){
    		alert("<bean:message key='Alarm.W1053.error' arg0='<%=inputTime%>'/>");
    		field.value = "";
    		field.focus();
    	}	
    	
    	return isValid;
    }
    
    function checkInputDate(field){
    	var mo, day, yr;
        var entry = field.value;
        var isValid = true;
        if(entry.length == 0){
    		return isValid;
    	}
        
        var delim = entry.indexOf("/");
        if (delim != -1) {
	        mo = parseInt(entry.substring(0, delim), 10);
	        day = parseInt(entry.substr(delim+1), 10);
	        yr = $('#txtYear').val();
	        
	        var testDate = new Date(yr, mo-1, day);
	        if (testDate.getFullYear() != yr) {
	        	isValid = false;
	        }
	        else if (testDate.getMonth() + 1 != mo) {
	        	isValid = false;
	        }
	        else if (testDate.getDate() != day) {
	        	isValid = false;
	        }
        }
        else {
        	isValid = false;
        }
    	
    	if(!isValid){
    		alert("<bean:message key='Alarm.W1053.error' arg0='<%=inputDate%>'/>");
    		field.value = "";
    		field.focus();
    	}
    	
    	return isValid;
    }
    
    function isNumeric(n)
    {
        var n2 = n;
        n = parseFloat(n);
        return (n!='NaN' && n2==n);
    }
    
    function checkJobDivision(jobId) {
    	var paidLeaveField = $("input[name*='paidHoliday']");
    	var isEnabled = $('#isEnabled').val();
    	if (paidLeaveField) {
	    	if (jobId == "A07") {
	    		if (isEnabled == "true") {
	    			$(paidLeaveField).removeAttr("disabled");
	    		}
	    	}
	    	else {
	    		$(paidLeaveField).val("");
	    		$(paidLeaveField).attr("disabled", "disabled");
	    	}
    	}
    	
    	var workingStartTimeVal = $("input[name*='workingStartTime']").val();
    	var workingEndTimeVal = $("input[name*='workingEndTime']").val();
    	//Job != A01 A02 A03 A04 A07 D05 D06
    	if ((jobId != "A01" && jobId != "A02" && jobId != "A03" && jobId != "A04" && jobId != "A05" && jobId != "A07" && jobId != "D05" && jobId != "D06")
    			|| (workingStartTimeVal == "" && workingEndTimeVal == "")){
    		$("input[name*='workingTimeCheckExclusionFlag']").val("true");
    	}
    	else {
    		$("input[name*='workingTimeCheckExclusionFlag']").val("false");
    	}
    }
    
    function deleteProject() {
    	var n = $("input:checked[name*='select']").length;
    	if (n < 1) {
    		alert("<bean:message key='Alarm.W1054.error' arg0='<%=project%>'/>");
    		return false;
    	}
    	return true;
    }
    
    function checkWorkCode(inputWorkCodeControl) {
    	//convert fullsize to halfsize
    	inputWorkCodeControl.value = chkCode(inputWorkCodeControl.value);
		if(inputWorkCodeControl.value.length == 0){
			$(trActived).find('label[id="workName"]').text("");
			$(trActived).find('input[id="hiddenWorkName"]').val("");
			return;
		}
		if(inputWorkCodeControl.value.length != 10){
			alert("<bean:message key='Alarm.W1098.error' arg0='Work Code '/>");
			$(trActived).find('label[id="workName"]').text("");
			$(trActived).find('input[id="hiddenWorkName"]').val("");
			//inputWorkCodeControl.focus();
		}
		else{
			$.getJSON("checkworkcode.do?workCode="+inputWorkCodeControl.value,
					function(data){
						var trActived = $(inputWorkCodeControl).parent().parent();
						//$(trActived).find('input[name*="workCode"]').val(data.workId);
						if(data != null){
							$(trActived).find('label[id="workName"]').text(data.workName);
							$(trActived).find('input[id="hiddenWorkName"]').val(data.workName);
						}
						else{
							$(trActived).find('label[id="workName"]').text("");
							$(trActived).find('input[id="hiddenWorkName"]').val("");
							alert("<bean:message key='Alarm.W1058.error' arg0='Work Code '/>");
							//inputWorkCodeControl.focus();
						}
					});
		}
	}
	
    function checkProjectCodeAndSeri(inputProjectControl){
    	inputProjectControl.value = chkCode(inputProjectControl.value);
		var seri="";
		var projectCode="";
		var isprojectCheck = false;
		var isseriCheck = false;
		var trActived = $(inputProjectControl).parent().parent();
		if(inputProjectControl.name.indexOf("projectCode")!= -1){
			isprojectCheck = true;
			projectChecked = true;
			projectCode = inputProjectControl.value;
			var seriField = $(trActived).find('input[name*="seri"]');
			seri = chkCode(seriField.val());
			seriField.val(seri);
		}
		else if(inputProjectControl.name.indexOf("seri")!= -1){
			seri = inputProjectControl.value;
			isseriCheck = true;
			var prjCodeField = $(trActived).find('input[name*="projectCode"]');
			projectCode = chkCode(prjCodeField.val());
			prjCodeField.val(projectCode);
		}
		if((projectCode == "" || projectCode == null) && (seri == null || seri == "")){
			return;
		}
		
		if(projectCode.length != 6 || seri.length != 2){
			$(trActived).find('label[id="projectName"]').text("");
			$(trActived).find('input[id="hiddenProjectName"]').val("");
			alert("<bean:message key='Alarm.W1098.error' arg0='Project code or seri ' />");
			return;
		}
		else{
			
			
				$.getJSON("checkprojectcode.do?projectCode="+projectCode+"&seri="+seri,
						function(data){
							if(data != null){
								$(trActived).find('label[id="projectName"]').text(data.projectName);
								$(trActived).find('input[id="hiddenProjectName"]').val(data.projectName);
							}
							else{
								$(trActived).find('label[id="projectName"]').text("");
								$(trActived).find('input[id="hiddenProjectName"]').val("");
								if(isprojectCheck == true && seriCheck == true){
					    			return;
					    		}
							
								if(projectChecked == true && seriCheck == false  && isseriCheck == true){
									seriCheck = true;
									return;
								}
								alert("<bean:message key='Alarm.W1058.error' arg0='Project Number '/>");
							}
						});
		}
		
	}
	
	function preSubmit() {
		var jobSelected = $("select[name*='jobDivision']").selectedValues();
		checkJobDivision(jobSelected[0]);
	}
	
	function confirmation(actionMessage) {
		var employeeCode = $('#employeeCode').text();
		var currentDate = $('#txtYear').val() + "/" + $('#txtMonth').val() + "/" + $('#txtDay').val();
		return confirm("<bean:message key='ENQ.Q0152' arg0='" + employeeCode + "' arg1='" + currentDate + "' arg2='" + actionMessage + "'/>");
	}
	
	function beforeConfirm() {
		return confirmation('<%=confirmMessage%>');
	}
	
	function beforeDelete() {
		return confirmation('<%=deleteMessage%>');
	}
	
	function checkProjectNameChange(selectedRowIndex){
		//do nothing
	}
	
	function checkWorkNameChange(selectedRowIndex){
		//do nothing
	}
	
	function resetWorkingTime(){
		$('#workingTime').text("");
		$('#workingTimeHidden').val("");
	}
	
</script>
<body>
<bean:define id="isEditable" type="Boolean" name="InputDailyAttendanceForm" property="isEditable" />
<bean:define id="isSaved" type="Boolean" name="InputDailyAttendanceForm" property="saveSuccess" />
<bean:define id="isDeleted" type="Boolean" name="InputDailyAttendanceForm" property="deleteSuccess" />
<bean:define id="isComfirmed" type="Boolean" name="InputDailyAttendanceForm" property="confirmSuccess" />
<bean:define id="isDeleteEnabled" type="Boolean" name="InputDailyAttendanceForm" property="isDeleteEnabled" />
<div style="color:red">
    <html:errors />
</div>
<html:form styleId="formInputDailyAttendance" action="inputdailyattendancetest" >
<html:hidden property="workingTimeCheckExclusionFlag"/>
<input type="hidden" id="currYear"/>
<input type="hidden" id="currMonth"/>
<input type="hidden" id="currDay"/>
<html:hidden styleId="dateChanged" property="dateChangeFlag"/>
<html:hidden styleId="isEnabled" property="isEditable"/>
<div class="container">
	<div class="part1"> 
   		<div class="lefpPart1">
	       	<label class="colorLable" style="width: 90px;"><bean:message key="inputdailyattendace.label.selectDay"/></label> 
	       	<html:text property="year" style="width:40" styleId="txtYear" readonly="true"></html:text><label><bean:message key="inputdailyattendace.label.year"/></label>
	       	 <input type="hidden" id="hiddenDatePick"/>
	       	<html:text property="month" style="width:30;text-align:center;" maxlength="2" styleId="txtMonth" readonly="true"></html:text><label><bean:message key="inputdailyattendace.label.month"/></label>
	       	<html:text property="day" style="width:30;text-align:center;" maxlength="2" styleId="txtDay" readonly="true"></html:text><label><bean:message key="inputdailyattendace.label.date"/></label> 
	       	<html:text property="dayOfWeek" style="width:25;text-align:center;font-size:12px;" styleId="txtDayName" readonly="true"></html:text>
	        <img id="datepickButton" src="<c:url value="/img/calendar.gif" />" class="trigger">
	        &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
	        <html:submit styleClass="input" property="method"><bean:message key="inputdailyattendace.button.show"/></html:submit>    
        </div>
        <div class="rightPart1">
        	<table id="buttonRightTable" width="180px" border="0" cellspacing="0" cellpadding="0">
  				<tr>
  					<td><html:submit styleId="btnDelete" style="width:60px;" styleClass="input" property="method" onclick="return beforeDelete();" disabled="<%=!isDeleteEnabled %>"><bean:message key="inputdailyattendace.button.delete"/></html:submit></td>
  					<td><html:submit styleId="btnSave" style="width:60px;"  styleClass="input" property="method" disabled="<%=!isEditable %>"><bean:message key="inputdailyattendace.button.save"/></html:submit></td>
   					<td><html:submit styleId="btnConfirm" style="width:60px;"  styleClass="input" property="method" disabled="<%=!isEditable %>" onclick="return beforeConfirm();"><bean:message key="inputdailyattendace.button.cofirm"/></html:submit></td>
  				</tr>
 				<tr>
   					<td colspan="2" style="text-align: right;font-size: 12px;"><bean:message key="inputdailyattendace.label.status"/></td>
   					<td class="tdShowAllBorder" style="text-align: center;" width="60px;">
   						<label id="dailyWorkingApprovalStatus"><bean:write name="InputDailyAttendanceForm" property="timeDTO.dailyWorkingApprovalStatus" />&nbsp;</label>
   					</td>
 			    </tr>
			</table>
        </div>
   		<!-- end .part1 -->	
    </div>
    <div class="part2">
    	<div class="leftPart2">
        	<label class="colorLable"><bean:message key="inputdailyattendace.label.employeeInfo"/></label> 
        </div>
        <div class="centerPart2">
        	<table id="employerTable" cellspacing="0" >
        		<tr>
    				<td class="tdShowAllBorder" width="100px" height="20px;" style="text-align:left;"><label id="employeeCode"><bean:write name="InputDailyAttendanceForm" property="initDTO.employerCode" /></label></td>
    				<td class="tdRemoveAllBoder" width="30px"></td>
		            <td class="tdShowAllBorder" width="130px" style="text-align:left;"><bean:write name="InputDailyAttendanceForm" property="initDTO.employerName" /></td>
		            <td class="tdRemoveLeftRightBorder" width="110px" style="text-align:left;"><bean:write name="InputDailyAttendanceForm" property="initDTO.divisionName" /></td>
		            <td class="tdShowAllBorder" width="110px" style="text-align:left;"><bean:write name="InputDailyAttendanceForm" property="initDTO.departmentName" /></td>	
        		</tr>
       		</table>
        </div>
        <div class="rightPart2">
        </div>
   		<!-- end .part2 -->	
    </div>
    <div class="part3">
    	<label class="colorLable"><bean:message key="inputdailyattendace.label.WorkingInfo"/></label> 
    	&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
        <html:submit styleId="btnReCalculate" styleClass="input" property="method" disabled="<%=!isEditable %>" onclick="preSubmit();"><bean:message key="inputdailyattendace.button.reCaculate"/> </html:submit><br/>
        <div id="tableTopLeftDiv">
        	<table id="workTableTopLeft">
       		<tr>
            	<td class="tdHeader" style="width: 90px;"><bean:message key="inputdailyattendace.label.plannedWorkingStartTime"/></td>
            	<td width="95px" class="grayCell">
            		<label id="plannedWorkingStartTime"><bean:write name="InputDailyAttendanceForm" property="timeDTO.plannedWorkingStartTime"/></label>
            	</td>
           		<td width="15px" style="text-align: center;border: none;"><bean:message key="inputdailyattendace.separator"/></td>
            	<td width="65px" class="grayCell">
            		<label id="plannedWorkingEndTime"><bean:write name="InputDailyAttendanceForm" property="timeDTO.plannedWorkingEndTime"/></label>
           		</td>
            	<td width="27px" style="border: none;"></td>
            	<td class="tdHeader" width="70px"><bean:message key="inputdailyattendace.label.timeSettingList"/></td>
            	<td width="50px">
            		<html:select styleId="timeDivision" name="InputDailyAttendanceForm" property="timeDTO.timeDivision" onchange="getWorkingTimeInfo(this.options[selectedIndex].value);" disabled="<%=!isEditable %>">
            			<html:optionsCollection property="timeSettingList"/>
					</html:select>
           	 	</td>
         	</tr>
          	<tr>
            	<td class="tdHeader"><bean:message key="inputdailyattendace.label.attendanceSettingList"/></td>
            	<td>
            		<html:select styleId="jobDivision" name="InputDailyAttendanceForm" property="timeDTO.jobDivision" styleClass="resetWorkingTime" onchange="checkJobDivision(this.options[selectedIndex].value);" disabled="<%=!isEditable %>">
            			<html:optionsCollection property="attendanceSettingList" />
            		</html:select>
            	</td>
            	<td colspan="3" style="border: none;">
            		<html:checkbox styleId="chokkoFlag" styleClass="kokiGroup" name="InputDailyAttendanceForm" property="stampActualResultDTO.chokkoFlag" disabled="true"><bean:message key="inputdailyattendace.checkBox.Chokko"/></html:checkbox>
            		<html:hidden property="stampActualResultDTO.chokkoFlag"/>
            		<html:checkbox styleId="chokkiFlag" styleClass="kokiGroup" name="InputDailyAttendanceForm" property="stampActualResultDTO.chokkiFlag" disabled="true"><bean:message key="inputdailyattendace.checkBox.Chokki"/></html:checkbox>
            		<html:hidden property="stampActualResultDTO.chokkiFlag"/>
            	</td>
            	<td class="tdHeader"><bean:message key="inputdailyattendace.label.substituteHoliday"/></td>
            	<td><html:text styleClass="checkDateField" styleId="substituteHoliday" property="substituteHoliday" style="width:70px;text-align:center;" disabled="<%=!isEditable %>"></html:text></td>
          	</tr>
          	<tr>
	            <td class="tdHeader"><bean:message key="inputdailyattendace.label.comeAndGoHomeTime"/></td>
	            <td class="grayCell">
	            	<label id="comingWorkDay"><bean:write name="InputDailyAttendanceForm" property="stampActualResultDTO.comingWorkDay"/></label>
	            </td>
	            <td class="grayCell" colspan="2">
	            	<label id="comingWorkTime"><bean:write name="InputDailyAttendanceForm" property="stampActualResultDTO.comingWorkTime"/></label>
	            </td>
	            <td style="text-align: center;border: none;"><bean:message key="inputdailyattendace.separator"/></td>
	            <td class="grayCell">
	            	<label id="leavingWorkDay"><bean:write name="InputDailyAttendanceForm" property="stampActualResultDTO.leavingWorkDay"/></label>
	            </td>
	            <td class="grayCell">
	            	<label id="leavingWorkTime"><bean:write name="InputDailyAttendanceForm" property="stampActualResultDTO.leavingWorkTime"/></label>
	            </td>
            </tr>
          	<tr>
	            <td class="tdHeader"><bean:message key="inputdailyattendace.label.comeAndHomeFact"/></td>
	            <td>
	            	<html:text styleId="startDatePicker" styleClass="checkDateField resetWorkingTime" property="timeDTO.workingStartDay" style="width:80px;text-align:center;" disabled="<%=!isEditable %>"></html:text>
	            	<div style="display: none;">
	            		<img id="startDateImg" src="<c:url value="/img/calendar.gif" />" class="trigger">
	            	</div> 
	            </td>
	            <td colspan="2"><html:text styleId="workingStartTime" property="timeDTO.workingStartTime" style="width:81px;text-align:center;" styleClass="inputTime resetWorkingTime" disabled="<%=!isEditable %>"></html:text></td>
	            <td style="text-align: center;border: none;"><bean:message key="inputdailyattendace.separator"/></td>
	            <td>
	            	<html:text styleId="endDatePicker" styleClass="checkDateField resetWorkingTime" property="timeDTO.workingEndDay" style="width:90px;text-align:center;" disabled="<%=!isEditable %>"></html:text>
	            	<div style="display: none;">
	            		<img id="endDateImg" src="<c:url value="/img/calendar.gif" />" class="trigger">
	            	</div> 
	            </td>
	            <td><html:text styleId="workingEndTime" property="timeDTO.workingEndTime" style="width:70px;text-align:center;" styleClass="inputTime resetWorkingTime" disabled="<%=!isEditable %>"></html:text></td>
          	</tr>
          		<tr>
	            <td class="tdHeader"><bean:message key="inputdailyattendace.label.workTime"/></td>
	            <td class="grayCell">
	            	<label id="workingTime"><bean:write name="InputDailyAttendanceForm" property="timeDTO.workingTime"/></label>
	            	<html:hidden styleId="workingTimeHidden" property="timeDTO.workingTime"/>
	            </td>
	            <td colspan="5" style="border: none;border-right: 1px solid;">&nbsp;&nbsp;&nbsp;</td>
	            </tr>
        </table>
        </div>
          <div id="tableTopRightDiv">
          <table id="workTableTopRight" style="margin-left: -1px;">
          <tr>
           		<td class="tdHeader"><bean:message key="inputdailyattendace.label.plannedWorkingTime"/></td>
           		<td width="70px" class="grayCell">
            		<label id="plannedWorkingTime"><bean:write name="InputDailyAttendanceForm" property="timeDTO.plannedWorkingTime"/></label>
           		</td>
           		<td width="110px" style="border: none;"></td>
         	</tr>
          	<tr>
            	<td class="tdHeader"><bean:message key="inputdailyattendace.label.autoOvertimeApplyTime"/></td>
            	<td class="grayCell">
            		<label id="autoOvertimeApplyTime"><bean:write name="InputDailyAttendanceForm" property="timeDTO.overtimeAutomaticApply"/></label>
           	 	</td>
           	 	<td width="110px" style="border: none;"></td>
          	</tr>
          	<tr>
	            <td class="tdHeader"><bean:message key="inputdailyattendace.label.lateTime"/></td>
	            <td colspan="2" style="text-align:left;border: none;">
	            	<html:checkbox styleId="comingLateFlag" styleClass="timeFlag" name="InputDailyAttendanceForm" property="timeDTO.comingLateFlag" disabled="<%=!isEditable %>"><bean:message key="inputdailyattendace.checkBox.late"/></html:checkbox>
	            	<html:hidden property="timeDTO.comingLateFlag"/>
	           		<html:checkbox styleId="leavingEarlyFlag" styleClass="timeFlag" name="InputDailyAttendanceForm" property="timeDTO.leavingEarlyFlag" disabled="<%=!isEditable %>"><bean:message key="inputdailyattendace.checkBox.early"/></html:checkbox>
	               	<html:hidden property="timeDTO.leavingEarlyFlag"/>
	               	<html:checkbox styleId="commutingDelayFlag" styleClass="timeFlag" name="InputDailyAttendanceForm" property="timeDTO.commutingDelayFlag" disabled="<%=!isEditable %>"><bean:message key="inputdailyattendace.checkBox.lateBecauseMove"/></html:checkbox>
	            	<html:hidden property="timeDTO.commutingDelayFlag"/>
	            </td>
            </tr>
          	<tr>
	            <td class="tdHeader"><bean:message key="inputdailyattendace.label.restTime"/></td>
	            <td class="grayCell"><html:text styleId="screenRestTime" property="timeDTO.restTime" styleClass="inputTime resetWorkingTime" style="width:70px;text-align:center;" disabled="<%=!isEditable %>"></html:text></td>
	            <td style="text-align:left;border: none;">
	            	<logic:equal name="InputDailyAttendanceForm" property="isEditable" value="false">
				   		<input id="btnRestTimeDetail" class="input" type="button" style="height: 20px;" value="<bean:message key="inputdailyattendace.button.detail"/>" disabled="disabled">
				   	</logic:equal>
				   	<logic:equal name="InputDailyAttendanceForm" property="isEditable" value="true">
				   		<input id="btnRestTimeDetail" class="input" type="button" style="height: 20px;" value="<bean:message key="inputdailyattendace.button.detail"/>" onclick="openRestDetailPopup();">
				   	</logic:equal>
	            </td>
         	</tr>
          	<tr>
	            <logic:equal name="InputDailyAttendanceForm" property="initDTO.paidVacationFlag" value="true">
		            <td class="tdHeader"><bean:message key="inputdailyattendace.label.paidHoliday"/></td>
		            <td><html:text styleId="paidHoliday" property="timeDTO.paidHoliday" styleClass="inputTime resetWorkingTime" style="width:70px;text-align:center;" disabled="<%=!isEditable %>"></html:text></td>
	            </logic:equal>
	            <logic:equal name="InputDailyAttendanceForm" property="initDTO.paidVacationFlag" value="false">
		            <td style="border: none;"></td>
	            </logic:equal>
	            <td style="border: none;"></td>
          	</tr>
          </table>
        </div>
          <div id="tableTopBottomDiv">
          <table id="workTableBottom" style="margin-top: -1px;">
          	<tr>
	            <td class="tdHeader"><bean:message key="inputdailyattendace.label.comment"/></td>
	            <td><html:text styleId="comment" property="timeDTO.comment" style="width:477px;text-align:center;" maxlength="50" disabled="<%=!isEditable %>"></html:text>
          	</tr>
          </table>
        </div>
        
        
    <!-- end .part3 -->	
    </div>
    <div class="part4">
   		<label class="colorLable"><bean:message key="inputdailyattendace.label.workingTimeInfo"/></label>
        <table id="workInfoTable" class="workInfoTable" style="width:530px;font-size:12px;" border="1" cellspacing="0" cellpadding="0">
        	<tr>
	            <td class="tdHeader"><bean:message key="inputdailyattendace.label.fixedWorkingTime"/></td>
	            <td class="grayCell">
	            	<label id="fixedWorkingTime"><bean:write name="InputDailyAttendanceForm" property="timeDTO.fixedWorkingTime"/></label>
	            </td>
	            <td class="tdHeader"><bean:message key="inputdailyattendace.label.substituteHolidayTime"/></td>
	            <td><html:text styleId="substituteHolidayTime" property="timeDTO.substituteHolidayTime" style="width:80px;text-align:center;" styleClass="inputTime" disabled="<%=!isEditable %>"></html:text></td>
	            <td class="tdHeader"><bean:message key="inputdailyattendace.label.insufficentTime"/></td>
	            <td class="grayCell">
	            	<!-- <html:text property="timeDTO.insufficentTime" styleClass="inputTime" style="width:80px;text-align:center;"></html:text> -->
	            	<label id="insufficentTime"><bean:write name="InputDailyAttendanceForm" property="timeDTO.insufficentTime" /></label>
	            </td>
           </tr>
           <tr>
           		<td class="tdHeader"><bean:message key="inputdailyattendace.label.overtime"/></td>
	            <td><html:text styleId="overtime" property="timeDTO.overtime" style="width:80px;text-align:center;" styleClass="inputTime" disabled="<%=!isEditable %>"></html:text></td>
	            <td class="tdHeader"><bean:message key="inputdailyattendace.label.satWorkingTime"/></td>
	            <td><html:text styleId="satWorkingTime" property="timeDTO.satWorkingTime" style="width:80px;text-align:center;" styleClass="inputTime" disabled="<%=!isEditable %>"></html:text></td>
	            <td class="tdHeader"><bean:message key="inputdailyattendace.label.holidayWorkTime"/></td>
	            <td><html:text styleId="holidayWorkTime" property="timeDTO.holidayWorkTime" style="width:80px;text-align:center;" styleClass="inputTime" disabled="<%=!isEditable %>"></html:text></td>
           </tr>
           <tr>
	            <td class="tdHeader"><bean:message key="inputdailyattendace.label.nightWorkTime"/></td>
	            <td><html:text styleId="nightWorkTime" property="timeDTO.nightWorkTime" style="width:80px;text-align:center;" styleClass="inputTime" disabled="<%=!isEditable %>"></html:text></td>
	            <td class="tdHeader"><bean:message key="inputdailyattendace.label.satNightWorkTime"/></td>
	            <td><html:text styleId="satNightWorkTime" property="timeDTO.satNightWorkTime" style="width:80px;text-align:center;" styleClass="inputTime" disabled="<%=!isEditable %>"></html:text></td>
	            <td class="tdHeader"><bean:message key="inputdailyattendace.label.holidayNightWorkTime"/></td>
	            <td><html:text styleId="holidayNightWorkTime" property="timeDTO.holidayNightWorkTime" style="width:80px;text-align:center;" styleClass="inputTime" disabled="<%=!isEditable %>"></html:text></td>
           </tr>
           <tr>
	            <td class="tdHeader" style="background-color:#FF6600;"><bean:message key="inputdailyattendace.label.overTimeWorkingPerMonth"/></td>
	            <td class="grayCell">
	            	<label id="overTimeWorkingPerMonth"><bean:write name="InputDailyAttendanceForm" property="overTimeWorkingPerMonth"/></label>
	            </td>
	            <td class="tdHeader"><bean:message key="inputdailyattendace.label.nightShiftWork"/></td>
	            <td><html:text styleId="nightShiftWork" property="timeDTO.nightShiftWork" style="width:80px;text-align:center;" styleClass="inputTime" disabled="<%=!isEditable %>"></html:text></td>
	            <td>&nbsp;&nbsp;</td>
	            <td>&nbsp;&nbsp; </td>
           </tr>
           <tr>
	            <td class="tdHeader"><bean:message key="inputdailyattendace.label.announcement"/></td>
	            <td colspan="5" class="grayCell">
	            	<label id="announcement"><bean:write name="InputDailyAttendanceForm" property="announcement"/></label>
	            </td>
           </tr>
        </table>

    <!-- end .part4 -->	
    </div>
    <div class="part5">
    	<table id="addDeleteButtonTable" style="width:760px;font-size:12px;" cellspacing="0" cellpadding="0">
			<tr height="22px">
				<td width="142px">
					<label class="colorLable"><bean:message key="inputdailyattendace.label.WorkingTimeOfProject"/></label>
				</td>
		 		<td width="56px">
		 			<html:submit styleId="btnAddEffort" styleClass="input" property="method" disabled="<%=!isEditable %>"><bean:message key="inputdailyattendace.button.addProject"/> </html:submit>
		 		</td>
		 		<td>
					<html:submit styleId="btnDeleteEffort" styleClass="input" property="method" disabled="<%=!isEditable %>" onclick="return deleteProject();"><bean:message key="inputdailyattendace.button.deleteProject"/> </html:submit>
				</td>
   			</tr>
   		</table>
    	<table id="headerProjectTable" class="tableProject" style="width:760px;font-size:12px;" border="1" cellspacing="0" cellpadding="0">
	   		<tr height="22px">
			    <th style="width: 30px;" ><bean:message key="inputdailyattendace.label.selectProject"/></th>
		        <th style="width: 110px;"><bean:message key="inputdailyattendace.label.projectCode"/></th>
		        <th style="width: 61px;"><bean:message key="inputdailyattendace.label.seri"/></th>
		        <th style="width: 80px;"><bean:message key="inputdailyattendace.label.projectName"/></th>
		        <th style="width: 117px;"><bean:message key="inputdailyattendace.label.workCode"/></th>
		        <th style="width: 100px;"><bean:message key="inputdailyattendace.label.workName"/></th>
		        <th style="width: 50px;"><bean:message key="inputdailyattendace.label.timeForProject"/></th>
		        <th style="background-color:#CCFFFF;"><bean:message key="inputdailyattendace.label.commenInWorkProject"/></th>
     	   </tr>
        </table>
    <div class="bottomScrollTable">
		  <logic:empty name="InputDailyAttendanceForm" property="projectInfoDTOList">
		   	<table id="emptyInfoProjecTable" class="tableProject" style="width:760px;font-size:12px;" border="1" cellspacing="0" cellpadding="0">
		    	<c:forEach begin="1" end="4">
		    		<tr height="22px">
				    	<td width="30px">&nbsp;&nbsp;</td>
				        <td width="110px">&nbsp;&nbsp;</td>
						<td width="30px">&nbsp;&nbsp;</td>
						<td width="30px">&nbsp;&nbsp;</td>
						<td width="80px">&nbsp;&nbsp;</td>
						<td width="90px">&nbsp;&nbsp;</td>
						<td width="26px">&nbsp;&nbsp;</td>
						<td width="100px">&nbsp;&nbsp;</td>
						<td width="50px">&nbsp;&nbsp;</td>
						<td>&nbsp;&nbsp;</td>
		           </tr>
		       </c:forEach> 
		     </table>
     	 </logic:empty>
   		 <logic:notEmpty name="InputDailyAttendanceForm" property="projectInfoDTOList">
		  	<table id="infoProjectTable" class="tableProject" style="width:760px;font-size:12px;" border="1" cellspacing="0" cellpadding="0">
		       <logic:iterate id="projectInfoDTOListObj" name="InputDailyAttendanceForm" property="projectInfoDTOList">
		           <tr height="22px">
			           <td><html:checkbox style="width:30px;" name="projectInfoDTOListObj" property="select" indexed="true" onchange="" disabled="<%=!isEditable %>"/></td>
			           <td><html:text style="width:110px;" styleClass="projectCodeCheck" name="projectInfoDTOListObj" property="projectCode" indexed="true" maxlength="8" disabled="<%=!isEditable %>"></html:text></td>
					   <td><html:text style="width:23px;" styleClass="projectSeriCheck" name="projectInfoDTOListObj" property="seri" indexed="true" maxlength="2" disabled="<%=!isEditable %>"></html:text></td>
					   <td width="30px"><input class="inputFind" type="button" value="<bean:message key="screen.button.search"/>" onclick="findProjectCode(this);"></td>
					   <td width="80px">
					   	 <label id="projectName"><bean:write name='projectInfoDTOListObj' property='projectName'/></label>
					     <html:hidden styleId="hiddenProjectName" name="projectInfoDTOListObj" property="projectName" indexed="true"/>
					   </td>
					   <td><html:text style="width:79px;" name="projectInfoDTOListObj" property="workCode" indexed="true" disabled="<%=!isEditable %>" onblur="checkWorkCode(this);"></html:text></td>
					   <td width="30px"><input class="inputFind" type="button" value="<bean:message key="screen.button.search"/>" onclick="findWorkCode(this);"></td>
					   <td width="100px">
					     <label id="workName"><bean:write name='projectInfoDTOListObj' property='workName'/></label>
					     <html:hidden styleId="hiddenWorkName" name="projectInfoDTOListObj" property="workName" indexed="true"/>
					   </td>
					   <td><html:text style="width:50px;text-align: center;" name="projectInfoDTOListObj" property="workingTime" indexed="true" maxlength="6" styleClass="workingTime" disabled="<%=!isEditable %>"></html:text></td>
					   <td><html:text style="width:203px;" name="projectInfoDTOListObj" property="comment" indexed="true" maxlength="40" disabled="<%=!isEditable %>"></html:text></td>
		           </tr>
		        </logic:iterate>
		        <c:if test="${fn:length(InputDailyAttendanceForm.projectInfoDTOList) lt 4}" >
				<c:forEach var="i" begin="1" end="${4 - fn:length(InputDailyAttendanceForm.projectInfoDTOList)}">
					<tr>
			            <td></td>
			            <td></td>
			            <td></td>
			            <td></td>
			            <td></td>
			            <td></td>
			            <td></td>
			            <td></td>
			            <td></td>
			            <td></td>
		          	</tr>
				</c:forEach>
			</c:if>
			</table>
		</logic:notEmpty>
		</div>
	    	<table id="totalTimeProjectTable" class="totalTimeProjectTable" style="width:760px;font-size:12px;" border="1" cellspacing="0" cellpadding="0">
				<tr height="22px">
			    	<td width="30px" class="tdShowTopBorder">&nbsp;&nbsp;</td>
			        <td width="110px" class="tdShowTopBorder">&nbsp;&nbsp;</td>
					<td width="30px" class="tdShowTopBorder">&nbsp;&nbsp;</td>
					<td width="30px" class="tdShowTopBorder">&nbsp;&nbsp;</td>
					<td width="80px" class="tdShowTopBorder">&nbsp;&nbsp;</td>
					<td width="90px" class="tdShowTopBorder">&nbsp;&nbsp;</td>
					<td width="33px" class="tdShowTopBorder">&nbsp;&nbsp;</td>
					<td class="tdShowAllBorder" width="100px" style="background-color:#C0C0C0;"><bean:message key="inputdailyattendace.label.totalTime"/></td>
					<td class="tdShowAllBorder" width="50px">
						<label id="totalEffort"></label>
						<html:hidden styleId="totalOperationTime" property="totalOperationTime"/>
					</td>
					<td class="tdShowTopBorder">&nbsp;&nbsp;</td>
			   </tr>
			</table>
	</div>
<!-- end .part5 -->	
     <div class="part6">
    <!-- end .part6 -->	
    </div>
  <!-- end .container -->
</div>
<script language="JavaScript">
	var employeeCode = $('#employeeCode').text();
	var currentDate = $('#txtYear').val() + "/" + $('#txtMonth').val() + "/" + $('#txtDay').val();
	if (<%=isSaved%>) {
		alert("<bean:message key='Inf.I0067.notice' arg0='" + employeeCode + "' arg1='" + currentDate + "' arg2='<%=saveSuccessMessage%>'/>");
	}
	if (<%=isComfirmed%>) {
		alert("<bean:message key='Inf.I0067.notice' arg0='" + employeeCode + "' arg1='" + currentDate + "' arg2='<%=confirmSuccessMessage%>'/>");
	}
	if (<%=isDeleted%>) {
		alert("<bean:message key='Inf.I0081.notice' arg0='" + employeeCode + "' arg1='" + currentDate + "' arg2='<%=confirmSuccessMessage%>'/>");
	}
</script>
<%@ include file="../dialog/project_code_search.jsp" %>
<%@ include file="../dialog/work_code_search.jsp" %>
<%@ include file="../dialog/rest_time_detail.jsp" %>
</html:form>
</body>
</html>
